#!/usr/bin/perl
use strict;
use 5.14.0;
use utf8;

use Spreadsheet::ParseExcel;

@ARGV == 1 || die "You must provide input file.";
my $parser = Spreadsheet::ParseExcel->new();
my $wb = $parser->parse($ARGV[0]);
$wb || die $parser->error();

open LOGS, '>', 'logs.html';
print LOGS <<END;
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" charset="utf-8"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" charset="utf-8"></script>
    <title>所有日志</title>
</head>
<body>
END

for my $ws ($wb->worksheets()) {
  my ($row_min,$row_max) = $ws->row_range();
  for my $row ($row_min..$row_max) {
      print LOGS <<END;
<div class="alert alert-info alert-dismissible" role="alert">
   <button type="button" class="close" data-dismiss="alert" aria-label="关闭">
     <span aria-hidden="true">&times;</span>
   </button>
END
      print LOGS '<h3>';
      print LOGS $ws->get_cell($row,0)->value();
      print LOGS '</h3>';

      print LOGS '<h4>';
      print LOGS $ws->get_cell($row,3)->value(), ',',$ws->get_cell($row,2)->value();
      print LOGS '</h4>';

      print LOGS '<p>',$ws->get_cell($row,1)->value(),'</p>';

      print LOGS '</div>';
  }

}

print LOGS <<END;
</body>
</html>
END

close LOGS;
